GrapeCity.Win.MultiRow Namespace > GcMultiRow Class > Sort Method : Sort(SortItem[],Int32,Int32) Method |
<FeatureAttribute(Name="Sort", Version="v5.0")> Public Overloads Sub Sort( _ ByVal sortItems() As SortItem, _ ByVal startRow As Integer, _ ByVal endRow As Integer _ )
Dim instance As GcMultiRow Dim sortItems() As SortItem Dim startRow As Integer Dim endRow As Integer instance.Sort(sortItems, startRow, endRow)
Exception | Description |
---|---|
System.ArgumentNullException | The sortItems parameter is a null reference (Nothing in Visual Basic). |
System.ArgumentException | The sortItems array has no items. |
System.InvalidOperationException | This method cannot be accessed when the Template is a null reference (Nothing in Visual Basic). -or- VirtualMode is true and DataSource is a null reference (Nothing in Visual Basic). |
System.ArgumentOutOfRangeException | The startRow is less than 0 or greater than the number of all sortable Rows minus 1. -or- The endRow is less than 0 or greater than the number of all sortable Rows minus 1. |
The method can sort multiple columns at the same time by using multiple SortItems.
This method allows advanced customization of the GcMultiRow sorting feature. In order to implement a highly customized sorting operation, you can write an event handler for the CellMouseClick event for ColumnHeaderCell and call this method with an instance of a class that implements the System.Collections.IComparer interface as a member of SortItem. In this case, you typically set the SortMode property to SortMode.Programmatic to disable automatic sorting and to leave room for a sorting glyph. When sorting by cells set to programmatic sort mode, you must display the sorting glyph yourself by setting the SortGlyphDirection property.
If the AllowUserToAddRows property value is true, the last row is always the last row. In this case, the sorting operator does not affect the last row (uncommitted new row).
If AllowUserToAddRows is true, the last Row is not sortable. If AllowUserToAddRows is false, all Rows are sortable.
void SortByCodeMultiCells() { SortItem sortItem1 = new SortItem(0, SortOrder.Ascending); SortItem sortItem2 = new SortItem(1, SortOrder.Descending); SortItem[] sortItems = new SortItem[] { sortItem1, sortItem2 }; this.gcMultiRow1.Sort(sortItems, 0, 0); }
Private Sub SortByCodeMultiCells() Dim sortItem1 As New SortItem(0, SortOrder.Ascending) Dim sortItem2 As New SortItem(1, SortOrder.Descending) Dim sortItems As SortItem() = New SortItem() {sortItem1, sortItem2} Me.gcMultiRow1.Sort(sortItems, 0, 0) End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2